<%@ include file="/WEB-INF/jsp/includes/include.jsp" %>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

	<head>
		<c:choose>
			<c:when test="${organisation.organisation.id == null}">
				<c:set var="title" value="Register your Organisation" scope="page" />
			</c:when>
			<c:otherwise>
				<c:set var="title" value="Edit Organisation" scope="page" />
			</c:otherwise>
		</c:choose>
	
		<title>${title}</title>

		<c:set var="form"><spring:theme code="form"/></c:set>
		<c:if test="${not empty form}">
			<link rel="stylesheet" href="<c:url value="${form}"/>" type="text/css" />
		</c:if>

	</head>

	<body>
		<h1>${title}</h1>

		<form:form method="post" commandName="organisation">
			
			<fieldset>
				<legend>Organisation Details</legend>
				<div>
					<label for="organisation.name" class="mandatoryField">Name:</span></label>
					<form:input path="organisation.name" id="organisation.name" size="50" maxlength="100" cssClass="text"/>
					<form:errors path="organisation.name" id="organisation.nameErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.yearFounded" class="mandatoryField">Year Founded:</label>	
					<form:input path="organisation.yearFounded" id="organisation.yearFounded" size="4" maxlength="4" cssClass="text"/>
					<form:errors path="organisation.yearFounded" id="organisation.yearFoundedErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.governmentOrganisation">Government Organisation:</label>	
					<form:checkbox path="organisation.governmentOrganisation" id="organisation.governmentOrganisation" />
					<form:errors path="organisation.governmentOrganisation" id="organisation.governmentOrganisationErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.summary" class="mandatoryField">Mission Statement:</label>				
					<form:input path="organisation.summary" id="organisation.summary" size="100" maxlength="300" cssClass="text"/>
					<form:errors path="organisation.summary" id="organisation.summaryErrors" cssClass="error"/>
				</div>				
				<div>
					<label for="organisation.description" class="mandatoryField">Description:</label>
					<form:textarea path="organisation.description" id="organisation.description" cols="80" rows="5" cssClass="textarea"/>
					<form:errors path="organisation.description" id="organisation.descriptionErrors" cssClass="error"/>
				</div>
				<div>
					<label for="serviceCategoryIds" class="mandatoryField">Service Categories:</label>
					<form:select path="serviceCategoryIds" multiple="true" items="${serviceCategories}" itemLabel="name" itemValue="id" size="5"/>
					<form:errors path="organisation.serviceCategories" id="serviceCategoryIdsErrors" cssClass="error"/>
				</div>
			</fieldset>
			
			<fieldset>
				<legend>Organisation Location:</legend>
				<div>
					<label for="organisation.location.number">Number:</label>
					<form:input path="organisation.location.number" id="organisation.location.number" size="8" maxlength="8" cssClass="text"/>
					<form:errors path="organisation.location.number" id="organisation.location.numberErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.location.street" class="mandatoryField">Street:</label>
					<form:input path="organisation.location.street" id="organisation.location.street" size="50" cssClass="text"/>
					<form:errors path="organisation.location.street" id="organisation.location.streetErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.location.suburb" class="mandatoryField">Suburb:</label>
					<form:input path="organisation.location.suburb" id="organisation.location.suburb" size="50" cssClass="text"/>
					<form:errors path="organisation.location.suburb" id="organisation.location.suburbErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.location.city" class="mandatoryField">City:</label>
					<form:input path="organisation.location.city" id="organisation.location.city" size="50" cssClass="text"/>
					<form:errors path="organisation.location.city" id="organisation.location.cityErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.location.state" class="mandatoryField">State:</label>
					<form:select path="organisation.location.state" id="organisation.location.state">
						<form:option label="Pick a state" value="" />
						<form:options items="${states}"/>
					</form:select>
					<form:errors path="organisation.location.state" id="organisation.location.stateErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.location.postcode" class="mandatoryField">Postcode:</label>
					<form:input path="organisation.location.postcode" id="organisation.location.postcode" size="4" maxlength="4" cssClass="text"/>
					<form:errors path="organisation.location.postcode" id="organisation.location.postcodeErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.location.country" class="mandatoryField">Country:</label>
					<form:select path="organisation.location.country" items="${countries}" id="organisation.location.country"/>
					<form:errors path="organisation.location.country" id="organisation.location.countryErrors" cssClass="error"/>
				</div>
			</fieldset>

			<fieldset>
				<legend>Operating Hours</legend>
				
				<div>
					<label for="organisation.availability.sundayStart.date">Sunday:</label>
					<form:checkbox path="organisation.availability.availableOnSunday"/>
					Open between
					<form:select path="organisation.availability.sundayStart.hourStr" items="${hours}" id="organisation.availability.sundayStart.hourStr"/>
					:
					<form:select path="organisation.availability.sundayStart.minuteStr" items="${minutes}" id="organisation.availability.sundayStart.minuteStr"/>
					and
					<form:select path="organisation.availability.sundayEnd.hourStr" items="${hours}" id="organisation.availability.sundayEnd.hourStr"/>
					:
					<form:select path="organisation.availability.sundayEnd.minuteStr" items="${minutes}" id="organisation.availability.sundayEnd.minuteStr"/>
				</div>
				<div>
					<label for="organisation.availability.mondayStart.date">Monday:</label>
					<form:checkbox path="organisation.availability.availableOnMonday"/>
					Open between
					<form:select path="organisation.availability.mondayStart.hourStr" items="${hours}" id="organisation.availability.mondayStart.hourStr"/>
					:
					<form:select path="organisation.availability.mondayStart.minuteStr" items="${minutes}" id="organisation.availability.mondayStart.minuteStr"/>
					and
					<form:select path="organisation.availability.mondayEnd.hourStr" items="${hours}" id="organisation.availability.mondayEnd.hourStr"/>
					:
					<form:select path="organisation.availability.mondayEnd.minuteStr" items="${minutes}" id="organisation.availability.mondayEnd.minuteStr"/>
				</div>
				<div>
					<label for="organisation.availability.tuesdayStart.date">Tuesday:</label>
					<form:checkbox path="organisation.availability.availableOnTuesday"/>
					Open between
					<form:select path="organisation.availability.tuesdayStart.hourStr" items="${hours}" id="organisation.availability.tuesdayStart.hourStr"/>
					:
					<form:select path="organisation.availability.tuesdayStart.minuteStr" items="${minutes}" id="organisation.availability.tuesdayStart.minuteStr"/>
					and
					<form:select path="organisation.availability.tuesdayEnd.hourStr" items="${hours}" id="organisation.availability.tuesdayEnd.hourStr"/>
					:
					<form:select path="organisation.availability.tuesdayEnd.minuteStr" items="${minutes}" id="organisation.availability.tuesdayEnd.minuteStr"/>
				</div>
				<div>
					<label for="organisation.availability.wednesdayStart.date">Wednesday:</label>
					<form:checkbox path="organisation.availability.availableOnWednesday"/>
					Open between
					<form:select path="organisation.availability.wednesdayStart.hourStr" items="${hours}" id="organisation.availability.wednesdayStart.hourStr"/>
					:
					<form:select path="organisation.availability.wednesdayStart.minuteStr" items="${minutes}" id="organisation.availability.wednesdayStart.minuteStr"/>
					and
					<form:select path="organisation.availability.wednesdayEnd.hourStr" items="${hours}" id="organisation.availability.wednesdayEnd.hourStr"/>
					:
					<form:select path="organisation.availability.wednesdayEnd.minuteStr" items="${minutes}" id="organisation.availability.wednesdayEnd.minuteStr"/>
				</div>
				<div>
					<label for="organisation.availability.thursdayStart.date">Thursday:</label>
					<form:checkbox path="organisation.availability.availableOnThursday"/>
					Open between
					<form:select path="organisation.availability.thursdayStart.hourStr" items="${hours}" id="organisation.availability.thursdayStart.hourStr"/>
					:
					<form:select path="organisation.availability.thursdayStart.minuteStr" items="${minutes}" id="organisation.availability.thursdayStart.minuteStr"/>
					and
					<form:select path="organisation.availability.thursdayEnd.hourStr" items="${hours}" id="organisation.availability.thursdayEnd.hourStr"/>
					:
					<form:select path="organisation.availability.thursdayEnd.minuteStr" items="${minutes}" id="organisation.availability.thursdayEnd.minuteStr"/>
				</div>
				<div>
					<label for="organisation.availability.fridayStart.date">Friday:</label>
					<form:checkbox path="organisation.availability.availableOnFriday"/>
					Open between
					<form:select path="organisation.availability.fridayStart.hourStr" items="${hours}" id="organisation.availability.fridayStart.hourStr"/>
					:
					<form:select path="organisation.availability.fridayStart.minuteStr" items="${minutes}" id="organisation.availability.fridayStart.minuteStr"/>
					and
					<form:select path="organisation.availability.fridayEnd.hourStr" items="${hours}" id="organisation.availability.fridayEnd.hourStr"/>
					:
					<form:select path="organisation.availability.fridayEnd.minuteStr" items="${minutes}" id="organisation.availability.fridayEnd.minuteStr"/>
				</div>
				<div>
					<label for="organisation.availability.saturdayStart.date">Saturday:</label>
					<form:checkbox path="organisation.availability.availableOnSaturday"/>
					Open between
					<form:select path="organisation.availability.saturdayStart.hourStr" items="${hours}" id="organisation.availability.saturdayStart.hourStr"/>
					:
					<form:select path="organisation.availability.saturdayStart.minuteStr" items="${minutes}" id="organisation.availability.saturdayStart.minuteStr"/>
					and
					<form:select path="organisation.availability.saturdayEnd.hourStr" items="${hours}" id="organisation.availability.saturdayEnd.hourStr"/>
					:
					<form:select path="organisation.availability.saturdayEnd.minuteStr" items="${minutes}" id="organisation.availability.saturdayEnd.minuteStr"/>
				</div>

			</fieldset>


			
			<fieldset>
				<legend>Contact Details</legend>
				<div>
					<label for="organisation.contactInfo.name" class="mandatoryField">Contact Name:</label>
					<form:input path="organisation.contactInfo.name" id="organisation.contactInfo.name" size="50" maxlength="100" cssClass="text"/>
					<form:errors path="organisation.contactInfo.name" id="organisation.contactInfoNameErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.emailAddress" class="mandatoryField">Email Address:</label>
					<form:input path="organisation.contactInfo.emailAddress" id="organisation.contactInfo.emailAddress" size="50" maxlength="100" cssClass="text"/>
					<form:errors path="organisation.contactInfo.emailAddress" id="organisation.contactInfoEmailAddressErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.homePhone">Home Phone:</label>
					<form:input path="organisation.contactInfo.homePhone" id="organisation.contactInfo.homePhone" size="50" cssClass="text"/>
					<form:errors path="organisation.contactInfo.homePhone" id="organisation.contactInfoHomePhoneErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.workPhone">Work Phone:</label>
					<form:input path="organisation.contactInfo.workPhone" id="organisation.contactInfo.workPhone" size="50" cssClass="text"/>
					<form:errors path="organisation.contactInfo.workPhone" id="organisation.contactInfoWorkPhoneErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.mobilePhone">Mobile Phone:</label>
					<form:input path="organisation.contactInfo.mobilePhone" id="organisation.contactInfo.mobilePhone" size="50" cssClass="text"/>
					<form:errors path="organisation.contactInfo.mobilePhone" id="organisation.contactInfoMobilePhoneErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.faxNumber">Fax Number:</label>				
					<form:input path="organisation.contactInfo.faxNumber" id="organisation.contactInfo.faxNumber" size="50" cssClass="text"/>
					<form:errors path="organisation.contactInfo.faxNumber" id="organisation.contactInfoFaxNumberErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.website">Website:</label>				
					<form:input path="organisation.contactInfo.website" id="organisation.contactInfo.website" size="50" cssClass="text"/>
					<form:errors path="organisation.contactInfo.website" id="organisation.contactInfoWebsiteErrors" cssClass="error"/>
				</div>
			</fieldset>
			
			<fieldset>
				<legend>Address</legend>
				<div>
					<label for="organisation.contactInfo.address.number">Number:</label>
					<form:input path="organisation.contactInfo.address.number" id="organisation.contactInfo.address.number" size="8" maxlength="8" cssClass="text"/>
					<form:errors path="organisation.contactInfo.address.number" id="organisation.contactInfo.addressNumberErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.address.street" class="mandatoryField">Street:</label>
					<form:input path="organisation.contactInfo.address.street" id="organisation.contactInfo.address.street" size="50" cssClass="text"/>
					<form:errors path="organisation.contactInfo.address.street" id="organisation.contactInfo.addressStreetErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.address.suburb" class="mandatoryField">Suburb:</label>
					<form:input path="organisation.contactInfo.address.suburb" id="organisation.contactInfo.address.suburb" size="50" cssClass="text"/>
					<form:errors path="organisation.contactInfo.address.suburb" id="organisation.contactInfo.addressSuburbErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.address.city" class="mandatoryField">City:</label>
					<form:input path="organisation.contactInfo.address.city" id="organisation.contactInfo.address.city" size="50" cssClass="text"/>
					<form:errors path="organisation.contactInfo.address.city" id="organisation.contactInfo.addressCityErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.address.state" class="mandatoryField">State:</label>
					<form:select path="organisation.contactInfo.address.state" id="organisation.contactInfo.address.state">
						<form:option label="Pick a state" value=""/>
						<form:options items="${states}"/>
					</form:select>
					<form:errors path="organisation.contactInfo.address.state" id="organisation.contactInfo.addressStateErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.address.postcode" class="mandatoryField">Postcode:</label>
					<form:input path="organisation.contactInfo.address.postcode" id="organisation.contactInfo.address.postcode" size="4" maxlength="4" cssClass="text"/>
					<form:errors path="organisation.contactInfo.address.postcode" id="organisation.contactInfo.addressPostcodeErrors" cssClass="error"/>
				</div>
				<div>
					<label for="organisation.contactInfo.address.country" class="mandatoryField">Country:</label>
					<form:select path="organisation.contactInfo.address.country" items="${countries}" id="organisation.contactInfo.address.country"/>
					<form:errors path="organisation.contactInfo.address.country" id="organisation.contactInfo.addressCountryErrors" cssClass="error"/>
				</div>
			</fieldset>
			
			<div>				
				<input type="submit" value="Submit" class="button"/>
			</div>
		</form:form>
													
	</body>
</html>

